package cn.bdqn.dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import cn.bdqn.bean.Teacher;

public class TeacherDaoImpl  implements TeacherDao {
private SessionFactory sessionFactory;
	@Override
	public void addTeacher(Teacher teacher) {
		sessionFactory.getCurrentSession().save(teacher);

	}

	@Override
	public void updateTeacher(Teacher teacher) {
		sessionFactory.getCurrentSession().update(teacher);
	}

	@Override
	public void deleteTeacher(Teacher teacher) {
		sessionFactory.getCurrentSession().delete(teacher);
	}

	@Override
	public List<Teacher> findTeachers() {

		return sessionFactory.getCurrentSession().find("from Teacher");
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

}
